<%@page import="java.text.Normalizer.Form"%>
<%@page import="org.springframework.security.core.context.SecurityContextHolder"%>
<%@page import="org.apache.commons.lang.StringUtils"%>
<%@page import="org.apache.commons.lang.time.DateFormatUtils"%>
<%@page import="org.springframework.util.CollectionUtils"%>
<%@page import="java.util.Collection"%>
<%@ include file="../common/common_include.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	UserInfo user = (UserInfo)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
	String username = user.getName();
	String siteid = user.getSiteId();
	AnalyzeForm form = (AnalyzeForm)request.getAttribute("command");
	String defaultSiteId = request.getAttribute("defaultSiteid")+"";
%>

<div>
	<form target="_coreIframe">
		<div class="breadcrumb">
			<div class="bcIcon"></div>
			<ul class="bcNav">
				<li>修改</li>
			</ul>
		</div>
		<table class="formTable">
			<tr>
				<td class="tdTitle">所属公司：</td>
				<td>
					<select id="siteList" class="easyui-combobox" name="siteid" style="width:100px;"></select>
					<span class="errorTipWrap" id="errorTip_siteid"></span>
				</td>
			</tr>
			<tr>
				<td class="tdTitle">员工：</td>
				<td>
					<ul id="users"></ul>
				</td>
			</tr>							
			<tr>
				<td class="tdTitle">开始日期：</td>
				<td>
				<input class="inputText xs" type="text" value="" name="startdate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})">
				<span class="errorTipWrap" id="errorTip_startdate"></span>
				</td>
			</tr>
			<tr>
				<td class="tdTitle">结束日期：</td>
				<td>
				<input class="inputText xs" type="text" value="" name="enddate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})">
				<span class="errorTipWrap" id="errorTip_enddate"></span>
				</td>
			</tr>								
			<tr>
				<td class="tdTitle"></td>
				<td>
					<div>
						
						<a id="analyzeBtn" class="input-btn-microsoft" href="javascript:XF.Check.submitAnalyzeForm()">提交</a>
						<!-- <a class="a-btn-microsoft" href="javascript:XF.NAV.navTo('/check')">取消</a> -->
						<div id="loading" style="display: none;"><img src="images/loading.gif"><span style="color: red;">正在分析，请勿关闭！</span></div>
						<div id="complete" style="display: none;">
							<span>分析完成</span>
						</div>
					</div>
				</td>
			</tr>	
		</table>
		<input type="hidden" value="<%=username %>" name="adduser"> 
		<input type="hidden" value="<%=siteid %>" name="entersite"> 	
	</form>
	<iframe id="_coreIframe" name="_coreIframe" style="display: none;"></iframe>
</div>
<script>
XF.Check.DefaultSiteId = '<%=defaultSiteId %>';
$('#siteList').combobox({
	url:global.contextPath + '/company/siteList',
	valueField:'siteid',
	textField:'sitename',
	onSelect:function(record){
		XF.Check.DefaultSiteId = record.siteid;
		getDeptsAndUsers(record.siteid);
	}
});

$('#siteList').combobox('setValue', '<%=defaultSiteId %>');

function getDeptsAndUsers(siteid) {
	$('#users').find('li').remove();
	$('#users').tree({
		url: global.contextPath + '/company/deptsAndUsers?siteid=' + siteid ,
		checkbox: true
	});
}
getDeptsAndUsers('<%=defaultSiteId %>');
</script>


